package my.jwds.p883;

public class ProjectionArea {

    public static void main(String[] args) {

        Solution obj = new Solution();
        long start = System.currentTimeMillis();
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    static class Solution {

        public int projectionArea(int[][] grid) {
            int zero = 0,res = 0,n = grid.length;

            for (int i = 0; i < n; i++) {
                int rowMax = 0;
                int colMax = 0;
                for (int j = 0; j < n; j++) {
                    if (grid[i][j] > rowMax) rowMax = grid[i][j];
                    if (grid[i][j] == 0)zero++;
                    if (grid[j][i] > colMax)colMax = grid[j][i];
                }
                res+= rowMax;
                res+= colMax;
            }


            res += n*n-zero;
            return res;
        }
    }
}